package com.aynu.gulimall.product.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author mj
 * @version 1.0
 * @date 2021/3/10 21:56
 */
@Configuration
public class MyRedissonConfig {

    public static final String REDIS_ADDRESS= "redis://192.168.150.130:6379";

    /**
     * 所有对redisson的操作，都通过RedissonClient来实现
     * @return
     */
    @Bean(destroyMethod = "shutdown")
    public RedissonClient redisson(){
        //创建配置
        Config config = new Config();
        config.useSingleServer().setAddress(REDIS_ADDRESS);
        //创建实例
        return Redisson.create(config);
    }
}
